import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86156
 * Date: 2023-04-09
 * Time: 22:39
 */
public class PhoneTest {
    public static void main(String[] args) {
        ArrayList<Phone> list = new ArrayList<>();
        Phone phone1 = new Phone("小米",1000);
        Phone phone2 = new Phone("苹果",8000);
        Phone phone3 = new Phone("锤子",2999);
        list.add(phone1);
        list.add(phone2);
        list.add(phone3);

        ArrayList<Phone> arr = new ArrayList<>();
        arr = returnPrice(list,3000);
        for (int i = 0; i < arr.size(); i++) {
                System.out.println(arr.get(i).getBrand()+" "+arr.get(i).getPrice());
        }
    }
    public static ArrayList<Phone> returnPrice(ArrayList<Phone> list ,int price){
        ArrayList<Phone> arr = new ArrayList<>();
        int index = 0;
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getPrice()<price){
                arr.add(list.get(i));
                index++;
            }
        }
        return arr;
    }
}
